home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / lib232.zip / INET-ON.SLT < prev    next >
Text File  |  1990-10-14  |  7KB  |  242 lines

  1. //////////////////////////////// INET-ON.SLT //////////////////////////////////
  2. //
  3. //  DESCRIPTION:  This script is included to demonstrate the use of the Custom
  4. //  Logon Script option that can be defined in each Configuration.  Also see
  5. //  INET-OFF.SLT for an example of a Custom Logoff Script.
  6. //
  7. //  CREDITS:  Password maintenance routine, and some other features modeled
  8. //  after a script originally created by Robert Wolfe.
  9. //  
  10. //  INSTRUCTIONS:  Before using this script, you must compile and run
  11. //  INETPASS.SLT.  The name of this script should then be placed in the Custom
  12. //  Logon Script option of a Liberator Configuration File, by typing INET-ON
  13. //  in the option.  The Liberator will dial the entry #(s) specified in the
  14. //  Configuration (should be the number for iNet) and open the Capture File
  15. //  defined (if any) before calling this script.  You can also use the dial
  16. //  starting time feature, available in each Command File, if you wish.  You
  17. //  must change the variables below to the proper values before re-saving and
  18. //  compiling with the command:
  19. //  CS INET-ON.  
  20. //  The name INET-OFF should also be placed in the Custom Logoff Script
  21. //  option. You must also compile INET-OFF.SLT with the command CS INET-OFF.
  22. //
  23. //  Note:  Your PCBoard password must be in the Telix dialing directory.
  24. //              ~~~~~~~
  25.                 
  26. int d = 5;       // delay before each response (in tenths/sec.)
  27.  
  28. str datapac_address[] =        "79100900",
  29.     user_id[] =                "Your.ID",     // change this to your iNet id.
  30.     inet_logon_command[] =     "A CRS GA";
  31.  
  32. //
  33. //////////////////////////////////////////////////////////////////////////////
  34. //  Nothing below should need changing.  Please remember to compile the script
  35. //  (CS INET-ON) before using it.
  36.  
  37. int f,
  38.     next_pos;
  39.  
  40. str pointer[3],
  41.     inet_password[8],
  42.     next_password[8],
  43.     password_file[64];
  44.  
  45. main()
  46. {
  47.  int t1,
  48.      t2,
  49.      t3,
  50.      t4,
  51.      t5,
  52.      t6,
  53.      t7,
  54.      t8;
  55.  
  56.  int tmark,
  57.      stat,
  58.      logon_complete = 0,
  59.      CR = '^M';
  60.  
  61. int i;
  62. str s[80];
  63.  
  64.  // Carrier detect, and PCBoard password already checked by The Liberator
  65.  // before calling this script.  If a capture file was defined in the Command
  66.  // File, it has also been opened by this point.
  67.  
  68.  if (!get_inet_password())        // Error getting iNet password.  Return
  69.   return(6);                      // abort code 6 to The Liberator.
  70.  
  71.  delay_scr(20);
  72.  cputs("...^M");                 // send 3 periods and a CR (1200 baud)
  73.  
  74.  if (waitfor("DATAPAC", 30))
  75.   {
  76.    delay_scr(d);
  77.    cputs(datapac_address);
  78.    cputc(CR);
  79.   }
  80.  else
  81.   return(10);
  82.  
  83.  t1 = track("/Code d'usager: ", 1);
  84.  t2 = track("/Code de securite: ", 1);
  85.  t3 = track("press <CR>", 1);
  86.  t4 = track("For your security",0);
  87.  t5 = track("Entered and re-entered",0);
  88.  t6 = track("Host did not accept Datapac call",1);
  89.  t7 = track("Unable to logon to host",0);
  90.  t8 = track("Logon to host computer completed", 1);
  91.  
  92.  tmark = timer_start(1800);                 // 3 minute max. for logon
  93.  
  94.  while (!time_up(tmark) && carrier())
  95.   {
  96.    terminal();
  97.    stat = track_hit(0);
  98.    
  99.    if (stat == t1)                     // send user-id
  100.     {
  101.      delay_scr(d);
  102.      cputs(user_id);
  103.      cputc(CR);
  104.     }
  105.  
  106.    else if (stat == t2)                     // send password
  107.     {
  108.      delay_scr(d);
  109.      cputs(inet_password);
  110.      cputc(CR);
  111.     }
  112.    
  113.    else if (stat == t3)                     // Access service from CR prompt
  114.     {
  115.      delay_scr(d);
  116.      cputs(inet_logon_command);
  117.      cputc(CR);
  118.     }
  119.     
  120.    else if (stat == t4)                     // password needs changing
  121.     {
  122.      waitfor("Please enter your old password", 30);
  123.      delay_scr(10);
  124.      cputs(inet_password);
  125.      cputc(CR);
  126.  
  127.      inet_password = next_password;
  128.  
  129.      waitfor("Please enter your new password", 30);
  130.      delay_scr(15);
  131.      cputs(inet_password);
  132.      cputc(CR);
  133.      waitfor("re-enter your new password", 30);
  134.      delay_scr(10);
  135.      cputs(inet_password);
  136.      cputc(CR);
  137.      f = fopen(password_file, "r+");   // open file to update pointer
  138.      itos(next_pos, pointer);
  139.      fwrite(pointer, 3, f);            // change password pointer
  140.      fclose(f);
  141.     }
  142.  
  143.    else if (stat == t5)
  144.     {
  145.      delay_scr(d);
  146.      cputs(inet_password);
  147.      cputc(CR);
  148.      waitfor("Please re-enter",10);
  149.      delay_scr(d);
  150.      cputs(inet_password);
  151.      cputc(CR);
  152.     }
  153.  
  154.    else if (stat == t6 || stat == t7)       // PCBoard not available/problems
  155.     break;                                  // say BYE/hangup below
  156.  
  157.    else if (stat == t8)                     // logon completed
  158.     {
  159.      logon_complete = 1;
  160.      clear_scr();
  161.      break;
  162.     }
  163.   }
  164.  
  165.  track_free(0);
  166.  
  167.  if (time_up(tmark) || !carrier() || !logon_complete)
  168.   {
  169.    timer_free(tmark);
  170.    if (Waitfor("iNet command",10))
  171.     {
  172.      cputs("BYE");
  173.      cputc(CR);
  174.     }
  175.    while (carrier())
  176.     {
  177.      hangup();
  178.      delay_scr(50);
  179.     }
  180.    return(29);          // Unsuccessful logon.  Send abort code.
  181.   }
  182.  
  183.  timer_free(tmark);
  184.  
  185.  return(0);            // normal termination
  186.  
  187. }
  188.  
  189. //////////////////////////////////////////////////////////////////////////////
  190. get_inet_password()
  191. {
  192.  int pos;
  193.  
  194.  password_file = _script_dir;     // Telix script directory (already checked)
  195.  strcat(password_file, "INETPASS.WRD");
  196.  
  197.  if (!filefind(password_file))
  198.   {
  199.    clear_scr();
  200.    prints("INETPASS.WRD file not found!  Disconnecting from iNet...");
  201.  
  202.    while (carrier())                 // No sense wasting iNet time while the
  203.     {                                // password file is created
  204.      hangup();
  205.      delay_scr(50);
  206.     }
  207.  
  208.    if (call("RUNME1ST") == -1)      // Attempt to create a password file
  209.     prints("Unable to create INETPASS.WRD");
  210.    delay(50);
  211.    return(0);                     // Abort the Command File
  212.   }
  213.  
  214.  f = fopen(password_file, "r");
  215.  if (!f)
  216.   return(0);
  217.  
  218.  fgets(pointer, 3, f);            // read first 3 char as pointer to password
  219.  pos = stoi(pointer);             // string to integer
  220.  fseek(f, pos, 0);                // position to start of password
  221.  fgets(inet_password, 9, f);      // get current password
  222.  next_pos = ftell(f);             // get position of next password
  223.  fgets(next_password, 9 , f);     // get next password as well
  224.  if (strlen(next_password) < 6)   // beyond last password
  225.   {
  226.    next_pos = 3;                  // reset pointer to start of passwords
  227.    fseek(f, 3, 0);                // set file pointer to start of passwords
  228.    fgets(next_password, 9, f);    // get next password
  229.   }
  230.  
  231.  fclose(f);
  232.  
  233.  if ((strlen(inet_password) < 6) || (strlen(next_password) < 6))
  234.   {
  235.    prints("Current iNet password, or next password in line is not valid.");
  236.    return(0);
  237.   }
  238.  
  239.  return(1);
  240. }
  241.  
  242. //////////////////////////////// End of file /////////////////////////////////